package com.hlt.shuiliting.dao;

import java.util.List;
import java.util.Map;

import com.hlt.shuiliting.database.DBUtil;
import com.hlt.shuiliting.valuebean.ZhongDaSJBG;

public class ZhongDaSJBGDAO {

	private int updateCount;
	
	public List list(int GongChengXMID) {
		String sql = "select * from ZhongDaSJBG where GongChengXMID = ?";
		Object[] params = {GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet();
		myDB.closed();
		
		return list;
	}
	
	public Map view(int id) {
		List list = null;
		String sql = "select * from ZhongDaSJBG where ID = ?";
		Object[] params = {id};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		list = myDB.getResultSet();
		Map map = (Map)list.get(0);
		
		return map;
	}
	public int insert(ZhongDaSJBG ZhongDaSJBG) {
		String sql = "insert ZhongDaSJBG values (seq_ZhongDaSJBG.nextVal, ?, to_date('?','yyyy-mm-dd'), ?,to_date('?','yyyy-mm-dd'), ?, ?, ?,?, ?, ?)";
		String ZhuangTai = ZhongDaSJBG.getZhuangTai();
		String JiLuSJ = ZhongDaSJBG.getJiLuSJ();
		String LuRuR = ZhongDaSJBG.getLuRuR();
		String SheJiXMBGSPSJ = ZhongDaSJBG.getSheJiXMBGSPSJ();
		String BianGengYY = ZhongDaSJBG.getBianGengYY();
		String TouZhiBH = ZhongDaSJBG.getTouZhiBH();
		String BianGengNR = ZhongDaSJBG.getBianGengNR();
		String ShenPiDW = ZhongDaSJBG.getShenPiDW();
		String ShenPiWH = ZhongDaSJBG.getShenPiWH();
		String XiangMuGCID = ZhongDaSJBG.getXiangMuGCID();
		Object[] params = {
				ZhuangTai,
				JiLuSJ,
				LuRuR,
				SheJiXMBGSPSJ,
				BianGengYY,
				TouZhiBH,
				BianGengNR,
				ShenPiDW,
				ShenPiWH,
				XiangMuGCID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int update(ZhongDaSJBG ZhongDaSJBG) {
		String sql = "update ZhongDaSJBG set ZhuangTai = ?, JiLuSJ = to_date('?','yyyy-mm-dd'), LuRuR = ?, SheJiXMBGSPSJ = to_date('?','yyyy-mm-dd'), " +
				"BianGengYY = ?, TouZhiBH = ?, BianGengNR = ?, ShenPiDW = ?, ShenPiWH = ?, " +
				"XiangMuGCID = ?, where ID = ?";
		String ID = ZhongDaSJBG.getID();
		String ZhuangTai = ZhongDaSJBG.getZhuangTai();
		String JiLuSJ = ZhongDaSJBG.getJiLuSJ();
		String LuRuR = ZhongDaSJBG.getLuRuR();
		String SheJiXMBGSPSJ = ZhongDaSJBG.getSheJiXMBGSPSJ();
		String BianGengYY = ZhongDaSJBG.getBianGengYY();
		String TouZhiBH = ZhongDaSJBG.getTouZhiBH();
		String BianGengNR = ZhongDaSJBG.getBianGengNR();
		String ShenPiDW = ZhongDaSJBG.getShenPiDW();
		String ShenPiWH = ZhongDaSJBG.getShenPiWH();
		String XiangMuGCID = ZhongDaSJBG.getXiangMuGCID();
		Object[] params = {
				ID,
				ZhuangTai,
				JiLuSJ,
				LuRuR,
				SheJiXMBGSPSJ,
				BianGengYY,
				TouZhiBH,
				BianGengNR,
				ShenPiDW,
				ShenPiWH,
				XiangMuGCID,
				ID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int delete(int id) {
		String sql = "delete from ZhongDaSJBG where ID = ?";
		Object[] params = {};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
}
